<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        img {
            opacity: 0;
        }
    </style>
    <script>
        var flag = true;

        function preview() {
            flag = !flag;
            var img = document.getElementById("im");
            if (flag) {
                img.style.cssText = "opacity:0";
            } else {
                img.style.cssText = "opacity:1";
            }

        }
    </script>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
    <input type="file" name="file"/>
    <input type="submit" value="上传文件"/>
    <img id="im" src="/previewImage?pathUrl=8f62b4ac82eb48e9a4e0bbd5c07d15d1.jpg" width="300px" height="300px">
</form>
<button onclick="preview()" id="btn">预览</button>
</body>
</html>